﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using NUnit.Framework;

namespace Common.Tests.System
{
    [TestFixture]
    public class DateTimeUtilsTests
    {
        #region IsInPast
        [Test]
        public void IsInPast_returns_true_for_MinValue()
        {
            Assert.True(DateTimeUtils.IsInPast(DateTime.MinValue));
        }

        [Test]
        public void IsInPast_returns_true_for_DateTime_Now_minus_one_sec()
        {
            Assert.True(DateTimeUtils.IsInPast(DateTime.Now.Subtract(TimeSpan.FromSeconds(1))));
        }

        [Test]
        public void IsInPast_Returns_false_for_future_date()
        {
            Assert.False(DateTimeUtils.IsInPast(DateTime.Today.AddDays(2)));
        }
        #endregion

        #region IsInFuture
        [Test]
        public void IsInFuture_returns_true_for_MaxValue()
        {
            Assert.True(DateTimeUtils.IsInFuture(DateTime.MaxValue));
        }

        [Test]
        public void IsInFuture_returns_true_for_DateTime_Now_minus_one_sec()
        {
            Assert.False(DateTimeUtils.IsInFuture(DateTime.Now.Subtract(TimeSpan.FromSeconds(1))));
        }

        [Test]
        public void IsInFuture_Returns_True_for_future_date()
        {
            Assert.True(DateTimeUtils.IsInFuture(DateTime.Today.AddDays(2)));
        }
        #endregion

        [Test]
        public void CoerceSubseconds_eliminates_Milliseconds()
        {
            var coerced = DateTime.Now.CoerceSubseconds();

            Assert.AreEqual(0, coerced.Millisecond);
        }
    }
}
